<?php
//$ip='219.138.151.138';
//$ip='127.0.0.1';
$ip='221.234.208.169';
$url='http://api.map.baidu.com/location/ip?ip='.$ip.'&ak=sAKN48wH88ZpWkcotjAaLQBioutOW1ch&coor=bd09ll';
$json=file_get_contents($url);
$obj=json_decode($json);

var_dump($obj);
$address= $obj->content->address;
var_dump($address);


function ipGetAdd($ip){
	$url='http://api.map.baidu.com/location/ip?ip='.$ip.'&ak=sAKN48wH88ZpWkcotjAaLQBioutOW1ch&coor=bd09ll';
	$json=file_get_contents($url);
	$obj=json_decode($json);
	$status=$obj->status;
	if($status==0){
		$address= $obj->content->address;
	}else{
		$address='--';
	}
	return $address;
}
echo ipGetAdd($ip);


